package com.ioffice.export.excel.engine.data.excel.impl.tree;

import java.util.List;

import org.apache.log4j.Logger;

import com.ioffice.exception.IOfficeException;
import com.ioffice.export.excel.data.ExcelSheetDataInfo;
import com.ioffice.export.excel.engine.data.excel.impl.AbstractEngineDataSheetCompent;
import com.ioffice.export.excel.sheet.cell.SheetCell;
import com.ioffice.export.excel.sheet.tree.SheetTitle;
import com.ioffice.export.excel.type.ExcelSheetType;

/**
 * 
 * @author <a href="mailto:goodluck.sunlight@gmail.com">chenboning</a>
 *
 * 
 * @descption 将ExcelSheetDataInfo中的数据转换为SheetTitle对象
 *
 * @version 1.0
 *
 *
 * @time  2013-5-21  下午4:28:24
 */
public class EngineDataSheetTreeTitle extends AbstractEngineDataSheetCompent{

	private Logger log=Logger.getLogger(this.getClass());
	private String errorMsg="";
	
	private SheetCell cell=null; 
	
	public EngineDataSheetTreeTitle() {
		if(compent==null){
			compent=new SheetTitle();
		}
	}
	
	@Override
	public void data2SheetCompent(List<ExcelSheetDataInfo> datas,ExcelSheetType sheetType) throws IOfficeException {
		cell=new SheetCell();
		cell.setCellValue(sheetType.getTitleName());
		try{
			compent.addChild(cell);
		}catch(IOfficeException e){
			errorMsg="SheetTitle 没有实例化 child 列表对象 "+e.toString();
			log.error(errorMsg);
			throw new IOfficeException(errorMsg);
		}
	}

}
